package com.xliu.cs.openproject.lianliankan.util;

import java.io.File;
import java.io.IOException;

public class CommandUtil {

    private CommandUtil() {

    }


    public static void openUriLink(String uri) throws IOException {
        String osName = System.getProperty("os.name");
        Runtime ce = Runtime.getRuntime();

        if (!osName.toLowerCase().contains("windows")) {
           throw new IOException("仅支持 Windows 系统");
        }

        String path = uri;

        if (uri.startsWith("./") || uri.startsWith("/") || uri.startsWith("file://")) {
            File file = new File(uri);
            path = file.getCanonicalPath();
        }

        ce.exec("cmd  /c  start " + path);
    }
}
